#
# Copyright (C) 2023, Inria
# GRAPHDECO research group, https://team.inria.fr/graphdeco
# All rights reserved.
#
# This software is free for non-commercial, research and evaluation use 
# under the terms of the LICENSE.md file.
#
# For inquiries contact  george.drettakis@inria.fr
#

from errno import EEXIST
from os import path
import os
from typing import Union
from pathlib import Path

BASE_PATH = Path(__file__).parent.parent.parent
DATA_PATH = BASE_PATH / 'data'

def mkdir_p(path: Union[str, Path], parents:bool=False) -> Path:
    p = path if isinstance(path, Path) else Path(path)
    p.mkdir(exist_ok=True, parents=parents)
    return p

def searchForMaxIteration(folder):
    saved_iters = [int(fname.split("_")[-1]) for fname in os.listdir(folder)]
    return max(saved_iters)
